SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].[usp_DeleteLecture] ( @JOL_Lecture_No INT )
AS 
    DECLARE @ID INT
    SET @ID = (
                SELECT  JOL_Lecture_Purpose
                FROM    dbo.JOL_Lecture
                WHERE   JOL_Lecture_No = @JOL_Lecture_No
              )
    DELETE  FROM dbo.JOL_ApplyField
    WHERE   JOL_Field_No = @ID
    DELETE  FROM dbo.JOL_Lecture
    WHERE   JOL_Lecture_No = @JOL_Lecture_No
GO
